<template>
  <div>
    <a-select v-model="text" placeholder="请选择" style="width: 175px" option-label-prop="label" @change="selectClick">
      <a-select-option v-for="(item, index) in dataForm" :key="index" :value="item.agencyCode" :label="item.agencyName">
        <div slot="title" style="display: flex; flex-direction: row; justify-content: space-between">
          <div>{{ item.agencyName }}</div>
          <div>{{ item.cityName }}</div>
        </div>
      </a-select-option>
    </a-select>
  </div>
</template>

<script>
import { getAction } from '@/api/manage'
export default {
  props: { value: '' },
  data () {
    return {
      dataForm: [],
      text: undefined
    }
  },
  created () {
    this.init()
  },
  methods: {
    init () {
      getAction('/xhdjAgency/list').then(res => {
        if (res.code === 200) {
          this.dataForm = res.result
        }
      })
    },
    selectClick (value) {
      this.$emit('selectClick', value)
    }
  },
  watch: {
    value (val) {
      if (!val) {
        this.text = undefined
      } else {
        return
      }
    }
  }
}
</script>

<style scoped></style>
